package android.support.v4.app;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.support.v4.c.c;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

public class FragmentActivity extends Activity
{
  final Handler a = new g(this);
  final m b = new m();
  final k c = new h(this);
  boolean d;
  boolean e;
  boolean f;
  boolean g;
  boolean h;
  boolean i;
  boolean j;
  boolean k;
  HashMap l;
  w m;

  private static String a(View paramView)
  {
    char c1;
    int i1;
    Object localObject;
    char c3 = 'F';
    char c2 = '.';
    StringBuilder localStringBuilder = new StringBuilder(128);
    localStringBuilder.append(paramView.getClass().getName());
    localStringBuilder.append('{');
    localStringBuilder.append(Integer.toHexString(System.identityHashCode(paramView)));
    localStringBuilder.append(' ');
    switch (paramView.getVisibility())
    {
    default:
      localStringBuilder.append('.');
      if (!(paramView.isFocusable()))
        break label556;
      c1 = 'F';
      localStringBuilder.append(c1);
      if (!(paramView.isEnabled()))
        break label562;
      c1 = 'E';
      localStringBuilder.append(c1);
      if (!(paramView.willNotDraw()))
        break label568;
      c1 = '.';
      localStringBuilder.append(c1);
      if (!(paramView.isHorizontalScrollBarEnabled()))
        break label574;
      c1 = 'H';
      localStringBuilder.append(c1);
      if (!(paramView.isVerticalScrollBarEnabled()))
        break label580;
      c1 = 'V';
      localStringBuilder.append(c1);
      if (!(paramView.isClickable()))
        break label586;
      c1 = 'C';
      localStringBuilder.append(c1);
      if (!(paramView.isLongClickable()))
        break label592;
      c1 = 'L';
      localStringBuilder.append(c1);
      localStringBuilder.append(' ');
      if (!(paramView.isFocused()))
        break label598;
      c1 = c3;
      localStringBuilder.append(c1);
      if (!(paramView.isSelected()))
        break label604;
      c1 = 'S';
      localStringBuilder.append(c1);
      c1 = c2;
      if (paramView.isPressed())
        c1 = 'P';
      localStringBuilder.append(c1);
      localStringBuilder.append(' ');
      localStringBuilder.append(paramView.getLeft());
      localStringBuilder.append(',');
      localStringBuilder.append(paramView.getTop());
      localStringBuilder.append('-');
      localStringBuilder.append(paramView.getRight());
      localStringBuilder.append(',');
      localStringBuilder.append(paramView.getBottom());
      i1 = paramView.getId();
      if (i1 == -1)
        break label509;
      localStringBuilder.append(" #");
      localStringBuilder.append(Integer.toHexString(i1));
      localObject = paramView.getResources();
      if ((i1 == 0) || (localObject == null))
        break label509;
      switch (0xFF000000 & i1)
      {
      default:
      case 2130706432:
      case 16777216:
      }
    case 0:
    case 4:
    case 8:
    }
    while (true)
      try
      {
        for (paramView = ((Resources)localObject).getResourcePackageName(i1); ; paramView = "app")
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          while (true)
                          {
                            while (true)
                            {
                              while (true)
                              {
                                while (true)
                                {
                                  String str = ((Resources)localObject).getResourceTypeName(i1);
                                  localObject = ((Resources)localObject).getResourceEntryName(i1);
                                  localStringBuilder.append(" ");
                                  localStringBuilder.append(paramView);
                                  localStringBuilder.append(":");
                                  localStringBuilder.append(str);
                                  localStringBuilder.append("/");
                                  localStringBuilder.append((String)localObject);
                                  label509: localStringBuilder.append("}");
                                  return localStringBuilder.toString();
                                  localStringBuilder.append('V');
                                }
                                localStringBuilder.append('I');
                              }
                              localStringBuilder.append('G');
                            }
                            label556: c1 = '.';
                          }
                          label562: c1 = '.';
                        }
                        label568: c1 = 'D';
                      }
                      label574: c1 = '.';
                    }
                    label580: c1 = '.';
                  }
                  label586: c1 = '.';
                }
                label592: c1 = '.';
              }
              label598: c1 = '.';
            }
            label604: c1 = '.';
          }
        paramView = "android";
      }
      catch (android.content.res.Resources.NotFoundException paramView)
      {
        break label509:
      }
  }

  private void a(String paramString, PrintWriter paramPrintWriter, View paramView)
  {
    int i2;
    paramPrintWriter.print(paramString);
    if (paramView == null)
      paramPrintWriter.println("null");
    do
    {
      do
      {
        return;
        paramPrintWriter.println(a(paramView));
      }
      while (!(paramView instanceof ViewGroup));
      paramView = (ViewGroup)paramView;
      i2 = paramView.getChildCount();
    }
    while (i2 <= 0);
    paramString = paramString + "  ";
    int i1 = 0;
    while (true)
    {
      if (i1 < i2);
      a(paramString, paramPrintWriter, paramView.getChildAt(i1));
      i1 += 1;
    }
  }

  final void a(String paramString)
  {
    if (this.l == null)
      return;
    w localw = (w)this.l.get(paramString);
    if ((localw == null) || (localw.g))
      return;
    localw.g();
    this.l.remove(paramString);
  }

  final void a(boolean paramBoolean)
  {
    if (!(this.g))
    {
      this.g = true;
      this.h = paramBoolean;
      this.a.removeMessages(1);
      if (this.k)
      {
        this.k = false;
        if (this.m != null)
        {
          if (this.h)
            break label67;
          this.m.c();
        }
      }
    }
    while (true)
    {
      this.b.a(2);
      return;
      label67: this.m.d();
    }
  }

  final w b(String paramString)
  {
    if (this.l == null)
      this.l = new HashMap();
    paramString = (w)this.l.get(paramString);
    if (paramString != null)
      paramString.e = this;
    return paramString;
  }

  public void dump(String paramString, FileDescriptor paramFileDescriptor, PrintWriter paramPrintWriter, String[] paramArrayOfString)
  {
    int i1 = Build.VERSION.SDK_INT;
    paramPrintWriter.print(paramString);
    paramPrintWriter.print("Local FragmentActivity ");
    paramPrintWriter.print(Integer.toHexString(System.identityHashCode(this)));
    paramPrintWriter.println(" State:");
    String str = paramString + "  ";
    paramPrintWriter.print(str);
    paramPrintWriter.print("mCreated=");
    paramPrintWriter.print(this.d);
    paramPrintWriter.print("mResumed=");
    paramPrintWriter.print(this.e);
    paramPrintWriter.print(" mStopped=");
    paramPrintWriter.print(this.f);
    paramPrintWriter.print(" mReallyStopped=");
    paramPrintWriter.println(this.g);
    paramPrintWriter.print(str);
    paramPrintWriter.print("mLoadersStarted=");
    paramPrintWriter.println(this.k);
    if (this.m != null)
    {
      paramPrintWriter.print(paramString);
      paramPrintWriter.print("Loader Manager ");
      paramPrintWriter.print(Integer.toHexString(System.identityHashCode(this.m)));
      paramPrintWriter.println(":");
      this.m.a(paramString + "  ", paramPrintWriter);
    }
    this.b.a(paramString, paramFileDescriptor, paramPrintWriter, paramArrayOfString);
    paramPrintWriter.print(paramString);
    paramPrintWriter.println("View Hierarchy:");
    a(paramString + "  ", paramPrintWriter, getWindow().getDecorView());
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    this.b.s = false;
    int i1 = paramInt1 >> 16;
    if (i1 != 0)
    {
      paramInt2 = i1 - 1;
      if ((this.b.f == null) || (paramInt2 < 0) || (paramInt2 >= this.b.f.size()))
      {
        Log.w("FragmentActivity", "Activity result fragment index out of range: 0x" + Integer.toHexString(paramInt1));
        return;
      }
      if ((Fragment)this.b.f.get(paramInt2) == null)
      {
        Log.w("FragmentActivity", "Activity result no fragment exists for index: 0x" + Integer.toHexString(paramInt1));
        return;
      }
      Fragment.b();
      return;
    }
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
  }

  public void onBackPressed()
  {
    if (this.b.c())
      return;
    finish();
  }

  public void onConfigurationChanged(Configuration paramConfiguration)
  {
    super.onConfigurationChanged(paramConfiguration);
    this.b.a(paramConfiguration);
  }

  protected void onCreate(Bundle paramBundle)
  {
    Parcelable localParcelable;
    m localm;
    this.b.a(this, this.c, null);
    if (getLayoutInflater().getFactory() == null)
      getLayoutInflater().setFactory(this);
    super.onCreate(paramBundle);
    j localj = (j)getLastNonConfigurationInstance();
    if (localj != null)
      this.l = localj.e;
    if (paramBundle != null)
    {
      localParcelable = paramBundle.getParcelable("android:support:fragments");
      localm = this.b;
      if (localj == null)
        break label101;
    }
    for (paramBundle = localj.d; ; paramBundle = null)
    {
      localm.a(localParcelable, paramBundle);
      this.b.g();
      label101: return;
    }
  }

  public boolean onCreatePanelMenu(int paramInt, Menu paramMenu)
  {
    if (paramInt == 0)
    {
      boolean bool1 = super.onCreatePanelMenu(paramInt, paramMenu);
      boolean bool2 = this.b.a(paramMenu, getMenuInflater());
      if (Build.VERSION.SDK_INT >= 11)
        return (bool1 | bool2);
      return true;
    }
    return super.onCreatePanelMenu(paramInt, paramMenu);
  }

  public View onCreateView(String paramString, Context paramContext, AttributeSet paramAttributeSet)
  {
    int i1;
    Object localObject = null;
    if (!("fragment".equals(paramString)))
      return super.onCreateView(paramString, paramContext, paramAttributeSet);
    paramString = paramAttributeSet.getAttributeValue(null, "class");
    paramContext = paramContext.obtainStyledAttributes(paramAttributeSet, i.a);
    String str1 = paramString;
    if (paramString == null)
      str1 = paramContext.getString(0);
    int i2 = paramContext.getResourceId(1, -1);
    String str2 = paramContext.getString(2);
    paramContext.recycle();
    paramContext = localObject;
    if (i2 != -1)
      paramContext = this.b.b(i2);
    paramString = paramContext;
    if (paramContext == null)
    {
      paramString = paramContext;
      if (str2 != null)
        paramString = this.b.a(str2);
    }
    paramContext = paramString;
    if (paramString == null)
      paramContext = this.b.b(0);
    if (m.a)
      Log.v("FragmentActivity", "onCreateView: id=0x" + Integer.toHexString(i2) + " fname=" + str1 + " existing=" + paramContext);
    if (paramContext == null)
    {
      paramString = Fragment.a(this, str1);
      paramString.o = true;
      if (i2 != 0)
      {
        i1 = i2;
        paramString.w = i1;
        paramString.x = 0;
        paramString.y = str2;
        paramString.p = true;
        paramString.s = this.b;
        paramContext = paramString.d;
        paramString.F = true;
        this.b.a(paramString, true);
      }
    }
    while (paramString.I == null)
    {
      while (true)
      {
        throw new IllegalStateException("Fragment " + str1 + " did not create a view.");
        i1 = 0;
      }
      if (paramContext.p)
        throw new IllegalArgumentException(paramAttributeSet.getPositionDescription() + ": Duplicate id 0x" + Integer.toHexString(i2) + ", tag " + str2 + ", or parent id 0x" + Integer.toHexString(0) + " with another fragment for " + str1);
      paramContext.p = true;
      if (!(paramContext.C))
      {
        paramString = paramContext.d;
        paramContext.F = true;
      }
      this.b.a(paramContext);
      paramString = paramContext;
    }
    if (i2 != 0)
      paramString.I.setId(i2);
    if (paramString.I.getTag() == null)
      paramString.I.setTag(str2);
    return paramString.I;
  }

  protected void onDestroy()
  {
    super.onDestroy();
    a(false);
    this.b.l();
    if (this.m == null)
      return;
    this.m.g();
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if ((Build.VERSION.SDK_INT < 5) && (paramInt == 4) && (paramKeyEvent.getRepeatCount() == 0))
    {
      onBackPressed();
      return true;
    }
    return super.onKeyDown(paramInt, paramKeyEvent);
  }

  public void onLowMemory()
  {
    super.onLowMemory();
    this.b.m();
  }

  public boolean onMenuItemSelected(int paramInt, MenuItem paramMenuItem)
  {
    if (super.onMenuItemSelected(paramInt, paramMenuItem))
      return true;
    switch (paramInt)
    {
    default:
      return false;
    case 0:
      return this.b.a(paramMenuItem);
    case 6:
    }
    return this.b.b(paramMenuItem);
  }

  protected void onNewIntent(Intent paramIntent)
  {
    super.onNewIntent(paramIntent);
    this.b.s = false;
  }

  public void onPanelClosed(int paramInt, Menu paramMenu)
  {
    switch (paramInt)
    {
    default:
    case 0:
    }
    while (true)
    {
      super.onPanelClosed(paramInt, paramMenu);
      return;
      this.b.b(paramMenu);
    }
  }

  protected void onPause()
  {
    super.onPause();
    this.e = false;
    if (this.a.hasMessages(2))
    {
      this.a.removeMessages(2);
      this.b.j();
    }
    this.b.a(4);
  }

  protected void onPostResume()
  {
    super.onPostResume();
    this.a.removeMessages(2);
    this.b.j();
    this.b.d();
  }

  public boolean onPreparePanel(int paramInt, View paramView, Menu paramMenu)
  {
    int i2 = 0;
    if ((paramInt == 0) && (paramMenu != null))
    {
      if (this.i)
      {
        this.i = false;
        paramMenu.clear();
        onCreatePanelMenu(paramInt, paramMenu);
      }
      int i1 = i2;
      if ((super.onPreparePanel(paramInt, paramView, paramMenu) | this.b.a(paramMenu)))
      {
        i1 = i2;
        if (paramMenu.hasVisibleItems())
          i1 = 1;
      }
      return i1;
    }
    return super.onPreparePanel(paramInt, paramView, paramMenu);
  }

  protected void onResume()
  {
    super.onResume();
    this.a.sendEmptyMessage(2);
    this.e = true;
    this.b.d();
  }

  public final Object onRetainNonConfigurationInstance()
  {
    int i1;
    int i2;
    Object localObject3;
    int i3 = 0;
    if (this.f)
      a(true);
    m localm = this.b;
    if (localm.f != null)
    {
      i1 = 0;
      localObject1 = null;
      localObject2 = localObject1;
      if (i1 >= localm.f.size())
        break label197;
      Fragment localFragment = (Fragment)localm.f.get(i1);
      localObject3 = localObject1;
      if (localFragment != null)
      {
        localObject3 = localObject1;
        if (localFragment.B)
        {
          localObject2 = localObject1;
          if (localObject1 == null)
            localObject2 = new ArrayList();
          ((ArrayList)localObject2).add(localFragment);
          localFragment.C = true;
          if (localFragment.i == null)
            break label189;
        }
      }
      label189: for (i2 = localFragment.i.f; ; i2 = -1)
        while (true)
        {
          localFragment.j = i2;
          localObject3 = localObject2;
          if (m.a)
          {
            Log.v("FragmentManager", "retainNonConfig: keeping retained " + localFragment);
            localObject3 = localObject2;
          }
          i1 += 1;
          localObject1 = localObject3;
        }
    }
    Object localObject2 = null;
    if (this.l != null)
    {
      label197: localObject1 = new w[this.l.size()];
      this.l.values().toArray(localObject1);
      i1 = 0;
      i2 = i3;
      i3 = i1;
      if (i2 >= localObject1.length)
        break label290;
      localObject3 = localObject1[i2];
      if (localObject3.g)
        i1 = 1;
      while (true)
      {
        while (true)
          i2 += 1;
        localObject3.g();
        this.l.remove(localObject3.d);
      }
    }
    i3 = 0;
    if ((localObject2 == null) && (i3 == 0))
      label290: return null;
    Object localObject1 = new j();
    ((j)localObject1).a = null;
    ((j)localObject1).b = null;
    ((j)localObject1).c = null;
    ((j)localObject1).d = ((ArrayList)localObject2);
    ((j)localObject1).e = this.l;
    return localObject1;
  }

  protected void onSaveInstanceState(Bundle paramBundle)
  {
    super.onSaveInstanceState(paramBundle);
    Parcelable localParcelable = this.b.f();
    if (localParcelable == null)
      return;
    paramBundle.putParcelable("android:support:fragments", localParcelable);
  }

  protected void onStart()
  {
    super.onStart();
    this.f = false;
    this.g = false;
    this.a.removeMessages(1);
    if (!(this.d))
    {
      this.d = true;
      this.b.h();
    }
    this.b.s = false;
    this.b.d();
    if (!(this.k))
    {
      this.k = true;
      if (this.m == null)
        break label331;
      this.m.b();
      this.j = true;
    }
    this.b.i();
    if (this.l == null)
      return;
    w[] arrayOfw = new w[this.l.size()];
    this.l.values().toArray(arrayOfw);
    int i1 = 0;
    while (i1 < arrayOfw.length)
    {
      w localw;
      while (true)
      {
        do
        {
          do
          {
            localw = arrayOfw[i1];
            if (!(localw.g))
              break label374;
            if (w.a)
              Log.v("LoaderManager", "Finished Retaining in " + localw);
            localw.g = false;
            int i2 = localw.b.a() - 1;
            while (true)
            {
              if (i2 < 0)
                break label374;
              x localx = (x)localw.b.b(i2);
              if (localx.i)
              {
                if (w.a)
                  Log.v("LoaderManager", "  Finished Retaining: " + localx);
                localx.i = false;
                if ((localx.h != localx.j) && (!(localx.h)))
                  localx.a();
              }
              if ((localx.h) && (localx.e) && (!(localx.k)))
                localx.a(localx.d, localx.g);
              label331: i2 -= 1;
            }
          }
          while (this.j);
          this.m = b(null);
        }
        while ((this.m == null) || (this.m.f));
        this.m.b();
      }
      label374: localw.f();
      i1 += 1;
    }
  }

  protected void onStop()
  {
    super.onStop();
    this.f = true;
    this.a.sendEmptyMessage(1);
    this.b.k();
  }

  public void startActivityForResult(Intent paramIntent, int paramInt)
  {
    if ((paramInt != -1) && ((0xFFFF0000 & paramInt) != 0))
      throw new IllegalArgumentException("Can only use lower 16 bits for requestCode");
    super.startActivityForResult(paramIntent, paramInt);
  }
}